let register = {
    elementMap: {},
    addComponent: function(panel) {
        this.elementMap[panel.id] = panel;
        return this;
    },
    removeComponent: function(panel) {
        if (this.elementMap[panel.id] && this.elementMap[panel.id] == panel) {
            delete this.elementMap[panel.id];
        }
        return this;
    },
    getComponentById: function(id) {
        return this.elementMap[id];
    },
    redraw: function(id, e) {
        let component = register.getComponentById(id);
        if (component && component.redraw) {
            component.redraw(e);
        }
        return this;
    },
    redrawAll: function(e) {
        for (let i in this.elementMap) {
            this.redraw(this.elementMap[i].id, e);
        }
        return this;
    }
};

export default register;